home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 735 b | 40 lines | [TEXT/ttxt] |
- --<<<
- -- Kaleida Labs, Inc.
- -- Field Guide to the ScriptX Language
- -- chapter 4, example 1
-
- --create a module to avoid naming conflicts
- module Scratch13 uses ScriptX end
- in module Scratch13
-
- -- case expression examples
-
- global pet := @snake
- case pet of
- @cat: print "meow"
- @dog: print "woof"
- @bird: print "chirp"
- @snake: print "hiss"
- otherwise: print "mysterious animal noise"
- end
-
- global i:0, bool
- bool := case i of
- 0:false
- 1:true
- otherwise: (print "out of range"; undefined)
- end
-
- global a:1, b:2
- case of
- (isComparable a b): (
- case of
- (a > b): print "a is greater than b"
- (a = b): print "a is equal to b"
- otherwise: print "a is less than b"
- end
- )
- otherwise: print "a and b are not comparable"
- end
- -->>>
-